import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const router = new VueRouter({
  mode: 'history',
  routes: [
    {
      path: '/',
      name: 'Login',
      component: () => import('../views/Login'),
    },
    {
      path: '/home',
      name: 'home',
      redirect: '/consultationOrder',
      component: () => import('../views/Home'),
      children: [
        {path: '/consultationOrder',  name: 'consultationOrder', component: () => import("../page/consultationOrder")},
        {path: '/doctorCertification',  name: 'doctorCertification', component: () => import("../page/doctorCertification")},
        {path: '/doctorClassification',  name: 'doctorClassification', component: () => import("../page/doctorClassification")},
        {path: '/doctorWithdrawal',  name: 'doctorWithdrawal', component: () => import("../page/doctorWithdrawal")},
        {path: '/numberConsultations',  name: 'numberConsultations', component: () => import("../page/numberConsultations")},
        {path: '/incomeScale',  name: 'incomeScale', component: () => import("../page/incomeScale")},
        {path: '/patient',  name: 'patient', component: () => import("../page/patient")},
        {path: '/abnormal',  name: 'abnormal', component: () => import("../page/abnormal")},
        {path: '/district',  name: 'district', component: () => import("../page/district")},
        {path: '/patientInformation',  name: 'patientInformation', component: () => import("../page/patientInformation")},
        {path: '/patientDisease',  name: 'patientDisease', component: () => import("../page/patientDisease")},
        {path: '/doctorInformation',  name: 'doctorInformation', component: () => import("../page/doctorInformation")},
        {path: '/doctorIncome',  name: 'doctorIncome', component: () => import("../page/doctorIncome")},
        {path: '/agreement',  name: 'agreement', component: () => import("../page/agreement")},
        {path: '/notice',  name: 'notice', component: () => import("../page/notice")},
        {path: '/illnessType',  name: 'illnessType', component: () => import("../page/illnessType")},
        {path: '/user',  name: 'user', component: () => import("../page/user")},
        {path: '/orderDetails',  name: 'orderDetails', component: () => import("../page/orderDetails")},
      ]
    }
  ]

})
// 导航守卫
// 使用 router.beforeEach 注册一个全局前置守卫，判断用户是否登陆
// router.beforeEach((to, from, next) => {
//   if (to.path === '/') {
//     next()
//   } else {
//     const token = window.sessionStorage.getItem('token')
//     if (!token) {
//       next('/')
//     } else {
//       next()
//     }
//   }
// })

export default router
